//导入express
const express = require('express');
//创建应用对象
const app = express();
//创建路由规则

//query请求风格
app.get('/user', (req, res) => {
  console.log(req.method);
  console.log(req.url);
  console.log(req.headers.host);


  console.log(req.path);
  console.log(req.query);
  let { name, pwd } = req.query;
  console.log(name + "," + pwd + "," + req.query.pwd);

  console.log(req.ip);


});

//restful请求风格
app.get('/user/:name/:pwd', (req, res) => {
  console.log('restful风格请求被触发');
  console.log(req.params);
  console.log(req.params.name + "," + req.params.pwd);
  res.end('restful风格请求');

})

//监听端口
app.listen(3000, () => {
  console.log('server is running at port 3000');
})
